Skip to content

[FEAT]: Canonical versioned trace/result serializer (WS0-05 PR 1) - #185

Draft
Nina Chikanov (nina-msft) wants to merge 5 commits into
microsoft:mainfrom
nina-msft:nina-msft-trace-result-schema-gate
Draft

[FEAT]: Canonical versioned trace/result serializer (WS0-05 PR 1)#185
Nina Chikanov (nina-msft) wants to merge 5 commits into
microsoft:mainfrom
nina-msft:nina-msft-trace-result-schema-gate

Conversation

@nina-msft

@nina-msft Nina Chikanov (nina-msft) commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

WS0-05 — PR 1: Canonical versioned trace/result serializer

First PR of the WS0-05 execution plan. This is a pure addition: existing consumers are not rewired here.

What this lands

  • rampart/core/serialization.py — the neutral, full-fidelity Resultdict round-trip. Its public surface is ResultRecord.to_dict() / from_dict() plus serialize_result() / deserialize_result() wrappers.
  • Single root version rampart.trace.v1 stamped on every record. Decoding dispatches through a version registry and fails closed on an unsupported major.
  • Current attribution collar — optional pytest_nodeid and result_index. They are omitted when not recorded; stable identity fields are deferred until their producer exists.
  • Defined value domain — closed enums encode to .value and fail closed on unsupported values; harm_category remains a passthrough string; floats must be finite; free-form mappings must be JSON-safe. Reserved transport bookkeeping keys are stripped from the canonical body.
  • Binary payloads fail closed because they are unsupported by rampart.trace.v1, rather than being coerced to PayloadFormat.TEXT.
  • Covers all 9 nested types, including PopulationRef.
  • Migration policy at docs/concepts/trace-schema.md: additive optional fields do not require a bump; structural changes require a new major; absence means not recorded; and future reserved collar fields are named.

Tests

tests/unit/core/test_serialization.py covers round-tripping, field exhaustiveness via dataclasses.fields(), version dispatch, additive tolerance, missing-field defaults, the supported value domain, attribution, and binary-payload rejection.

Still to do in this draft

  • Generate the open trace.v1.schema.json from encoder output and add a drift gate.

Introduce rampart/core/serialization.py as the single, neutral
full-fidelity Result <-> dict round-trip (Decision D6 gate). Every
record carries a single root version (rampart.trace.v1) and decoding
dispatches on it, failing closed on an unknown major.

The canonical layer defines the supported value domain only: enums
encode to .value and fail closed on unknown values, harm_category is a
passthrough string, floats must be finite, and free-form maps must be
JSON-safe. Transport hygiene (ANSI stripping, float normalization,
repr() fallback, size caps) stays at the xdist boundary and is not
duplicated here. Binary payloads fail closed pending the WS7 artifact
resolver rather than being coerced to text.

Also lands the written migration policy (docs/concepts/trace-schema.md):
additive-optional = no bump, structural = major bump, missing = not
recorded, readers fail closed on unknown major, with named reserved
additive slots so WS8 provenance needs no hard migration.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

Describe only the canonical serializer behavior present on this branch,
express later migration and consumer work as policy constraints, generalize
future additions outside the reserved collar fields, and remove the ship gate.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Comment thread rampart/core/serialization.py Outdated
Comment thread rampart/core/serialization.py Outdated
Comment thread rampart/core/serialization.py Outdated
Comment thread rampart/core/serialization.py Outdated
Comment thread rampart/core/serialization.py Outdated
Comment thread rampart/core/serialization.py Outdated
Comment thread rampart/core/serialization.py Outdated
Comment thread rampart/core/serialization.py Outdated
Remove planning references, place constant comments before declarations,
drop the unused identity origin field, and make unsupported binary payload
messages independent of planned work.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Remove identity and case_id until their producer is implemented, keep the
existing pytest attribution fields optional, and make the reserved metadata
constant private.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Fail closed on malformed collection fields, incomplete population references,
and non-string harm categories. Validate result indices before serialization so
the encoder cannot emit boolean indices rejected by the decoder.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant